def triangle(x):
    if not (isinstance(x ,int) and x>0):
        return "请输入一个正整数参数:"
    lst=[[str(j) for j in range(x-i,0,-1)] for i in range(x)]
    w=len(' '.join(lst[0]))

    print("上三角：")
    for i in range(1,x+1):
        print("{:>{width}}".format(' '.join(lst[-i]),width=w))

    print("下三角：")
    for i in range(x):
        print("{:>{width}}".format(' '.join(lst[i]),width=w))
        
triangle(12)


# 做得很不错
